<template>
  <view class="tabs">
    <view
      class="tab"
      :class="[tab.id === current ? 'active' : '', wrapClass]"
      v-for="(tab, tIndex) in tabs"
      :key="tIndex"
      @click="onClick(tab, tIndex)"
    >
      <view class="text">
        {{ tab.text }}
      </view>

      <view class="line"></view>
    </view>
  </view>
</template>

<script>
export default {
  props: {
    tabs: Array,
    current: Number,
    wrapClass: String,
	backgound: {
		type:String,
		default: 'linear-gradient(180deg, #0D1523 0%, #102945 100%)'
	}
  },
  methods: {
    onClick(tab, index) {
      this.$emit("change", tab, tab.id);
    },
  },
};
</script>

<style lang="stylus" scoped>
@import '~@/common/stylus/variable';

.tabs {
  display: flex;
  // background: linear-gradient(180deg, #0D1523 0%, #102945 100%);

  > .tab {
    position: relative;
    display: flex;
    flex: 0 0 176rpx;
    height: 72rpx;
    text-align: center;
    border-radius: 0 10rpx 0 0;
    margin-right: 3rpx;
    align-items: center;
    justify-content: center;

    >.line {
      position: absolute;
      z-index: 2;
      content: '';
      width: 48rpx;
      height: 4rpx;
      bottom: 0;
      left: 0;
      right: 0;
      background: #252e43;
      border-radius: 3rpx;
      margin: auto;
      transition: all 0.3s;
      transform: scaleX(0);
    }

    >.text {
      position: relative;
      z-index: 5;
      text-align: center;
      color: #999999;
      font-family: PingFangSC-Regular, PingFang SC;
    }

    &:after, &:first-child:before {
      position: absolute;
      z-index: 1;
      content: '';
      width: 100%;
      height: 100%;
      left: 0;
      top: 0;
      background: #252e43;
      border-radius: 0 10rpx 0 0;
      transform: skew(15deg);
    }

    &:first-child:before {
      width: 30%;
      transform: skew(0);
    }

    &.active {
      >.text {
        color: white;
        font-weight: 600;
      }

      >.line {
        transform: scaleX(1);
      }

      &:after, &:first-child:before {
        background: #252e43;
      }
    }
  }
}
</style>